package com.h2.ref.server.user;

import java.math.BigInteger;
import java.security.MessageDigest;

public class UserPasswordProvider {
   
   public String encrypt(String password) {
      MessageDigest messageDigest = null;
      try {
         messageDigest = MessageDigest.getInstance("MD5");
      } catch (Exception exp) {}
      messageDigest.update(password.getBytes(), 0, password.length());
      String hashedPass = new BigInteger(1,
            messageDigest.digest()).toString(16);
      if (hashedPass.length() < 32) {
         hashedPass = "0" + hashedPass;
      }
      return hashedPass;
   }

}
